import BaseAd from "../base/BaseAd";
import { SDKState, ResultState } from "../../SDKDefine";
export default abstract class BaseRewardAd extends BaseAd {
    // open() {

    //     console.log(' BaseRewardAd open state ', this.state)
    //     if (this.state == SDKState.loadSucess) {
    //         this.show()
    //     } else {
    //         this.preload(SDKState.open)
    //     }
    // }

    // preload(s: SDKState) {
    //     this.setLogicState(s);
    //     this.setState(SDKState.loading)
    //     this.destroy();
    //     this.create();
    // }

    init() {
        this.preload();
    }

    hide(): void {

    }



    load() {
        if (this.ad) {
            this.ad.load();
        }
    }

    show() {
        if (this.ad) {
            this.ad.show().then(() => {
                this.pause()
            }).catch(() => {
                this.ad.load()
                    .then(() => {
                        this.ad.show()
                    })
                    .catch((err: any) => {
                    })
            })
        }
    }

    // onLoad() {

    //     this.setState(SDKState.loadSucess)
    // }

    abstract destroy(): void

    onClose(res: any) {
        console.log('NativeTest onClose ', res)
        if (res && res.isEnded || res === undefined) {
            this.callResultCallback(ResultState.YES)
        } else {
            this.callResultCallback(ResultState.NO)
        }
        this.resume()
    }
}